<template>
  <view class="setting">
    <nav-bar title="设置" backgroundColor="#115BAA" titleColor="#FFF"></nav-bar>
    <view class="about-us" @click="clickAboutUs">
      <view class="label">关于我们</view>
      <uni-icons class="arrow-icon" type="right" color="#000" size="16"></uni-icons>
    </view>
    <view class="protocol-box">
      <view class="service" @click="clickService">
        <view class="label">用户服务协议</view>
        <uni-icons class="arrow-icon" type="right" color="#000" size="16"></uni-icons>
      </view>
      <view class="line"></view>
      <view class="privacy" @click="clickPrivacy">
        <view class="label">用户隐私协议</view>
        <uni-icons class="arrow-icon" type="right" color="#000" size="16"></uni-icons>
      </view>
    </view>
    <view class="version-box">
      当前版本：v1.1.1
    </view>
    <view class="login-out" @click="clickOut">退出登录</view>
  </view>
</template>

<script>
  import { removeToken } from '@/utils/auth'
  import api_login from '@/api/login'
  export default {
    name: 'SettingIndex',
    data() {
      return {

      }
    },
    onLoad() {},
    methods: {
      clickAboutUs() {
        uni.navigateTo({
          url: '/subPages/commonPage/settingPage/aboutUs'
        })
      },
      clickService() {
        uni.navigateTo({
          url: '/subPages/commonPage/settingPage/serviceProtocol'
        })
      },
      clickPrivacy() {
        uni.navigateTo({
          url: '/subPages/commonPage/settingPage/privacyProtocol'
        })
      },
      clickOut() {
        api_login.logout().then(res => {
          if (res.code !== 200) return
          uni.reLaunch({ url: '/subPages/home/login' })
          removeToken()
          uni.clearStorageSync('allUserInfo')
        })
      }
    }
  }
</script>
<style lang="scss" scoped>
  .setting {
    height: 100vh;
    background-color: #f0f3f5;
    .about-us,
    .protocol-box {
      padding: 0 40rpx;
      margin: 0 30rpx;
      border-radius: 16rpx;
      font-size: 32rpx;
      color: #000;
      background-color: #FFF;
      box-shadow: 0rpx 2rpx 2rpx  rgba(0, 0, 0, .2);
    }
    .about-us,
    .service,
    .privacy {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 80rpx;
    }
    .about-us {
      margin: 20rpx 30rpx;
    }
    .line {
      width: 100%;
      height: 2rpx;
      background-color: #EEE;
    }
    .version-box {
      margin-top: 80rpx;
      text-align: center;
      color: #A8A8A8;
    }
  }
  .login-out {
    height: 90rpx;
    margin: 100rpx 30rpx 0;
    border-radius: 45rpx;
    text-align: center;
    line-height: 90rpx;
    font-size: 32rpx;
    color: #FFF;
    background-color: #115baa;
  }
</style>
